
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>修改文档</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../res/layui/css/layui.css">
  <link rel="stylesheet" href="../../res/css/global.css">
  <script src="/js/jquery.min.js"></script>
  <script src="/js/common.variate.js"></script>
  <script src="/js/common.method.js"></script>
  <link rel="stylesheet" href="/css/header.css">
</head>
<body>

<div class="fly-header layui-bg-black">
  <div class="layui-container">
    <a class="fly-logo" href="/">
      <img src="/images/logo.png" alt="layui" style="width: 105px;">
    </a>
    <ul class="layui-nav fly-nav-user" id="tabYe">

    </ul>
  </div>
</div>
<div class="layui-container fly-marginTop">
  <div class="fly-panel" pad20 style="padding-top: 5px;">
    <!--<div class="fly-none">没有权限</div>-->
    <div class="layui-form layui-form-pane">
      <div class="layui-tab layui-tab-brief" lay-filter="user">
        <ul class="layui-tab-title">
          <li class="layui-this">修改文档</li>
        </ul>
        <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
          <div class="layui-tab-item layui-show">
            <!--<form action="" method="post">-->
              <div class="layui-col-md6" style="padding: 5px;">
                <div class="layui-form-item">
                  <label class="layui-form-label">文档标题</label>
                  <div class="layui-input-block">
                    <input th:value="${title}" id="title" type="text" name="title" required="" lay-verify="required" placeholder="必填" autocomplete="off" class="layui-input" />
                  </div>
                </div>
              </div>
              <div class="layui-col-md6" style="padding: 5px;">
                <div class="layui-form-item">
                  <label class="layui-form-label">标签</label>
                  <div class="layui-input-block">
                    <input th:value="${labels}" id="label" type="text" name="alias" required="" lay-verify="required" placeholder="多个标签以“,”分割，必填" autocomplete="off" class="layui-input" />
                  </div>
                </div>
              </div>

              <div class="layui-col-md12" style="padding: 5px;">
                <div class="layui-form-item layui-form-text">
                  <label class="layui-form-label">简单描述组件功能</label>
                  <div class="layui-input-block">
                    <textarea  th:text="${description}" id="description" name="desc" placeholder="必填" class="layui-textarea" autocomplete="off" style="min-height: 60px;"></textarea>
                  </div>
                </div>
              </div>
              <div class="layui-form-item layui-form-text" style="padding: 5px;">
                <div class="layui-input-block">
                  <textarea th:text="${content}" id="content" name="content" required lay-verify="required" placeholder="详细描述，必填" class="layui-textarea fly-editor" style="height: 360px;"></textarea>
                </div>
              </div>
              <div class="layui-col-md12" style="padding: 5px;">
                <div class="layui-form-item">
                  <label class="layui-form-label layui-text"><a href="http://192.168.0.240:7878" target="_blank">Gitlab</a> 地址</label>
                  <div class="layui-input-block">
                    <input th:value="${gitlaburl}" id="gitlabUrl" type="text" name="github" placeholder="组件在 Gitlab 的仓库地址，必填" autocomplete="off" class="layui-input" />
                  </div>
                </div>
              </div>
              <div class="layui-form-item" style="padding: 5px;">
                <button class="layui-btn" lay-filter="*" lay-button onclick="updateDoc()">立即更新</button>
              </div>
            <!--</form>-->
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<div class="fly-footer">
  <p> 2018 &copy; <a href="https://gitee.com/chaofan2685_admin" target="_blank">炒饭 出品</a></p>
  <p>
    <a href="http://www.lishiots.com/" target="_blank">力石科技</a>
    <a href="tencent://message/?uin=894195915&Site=http://vps.shuidazhe.com&Menu=yes">交个朋友</a>
    <a href=mailto:chaofan2685@qq.com>问题反馈</a>
  </p>
</div>


<script src="../../res/layui/layui.all.js"></script>
<script>
  layui.cache.page = 'jie';
  layui.cache.user = {
    username: '游客'
    ,uid: -1
    ,avatar: '../../res/images/avatar/00.jpg'
    ,experience: 83
    ,sex: '男'
  };
  layui.config({
    version: "3.0.0"
    ,base: '../../res/mods/'
  }).extend({
    fly: 'index'
  }).use('fly');

  checkLogin2();

  function updateDoc() {
      var title = $("#title").val();
      var gitlabUrl = $("#gitlabUrl").val();
      var content = $("#content").val();
      var label = $("#label").val();
      var description = $("#description").val();
      if (isEmpty(title) || isEmpty(gitlabUrl) || isEmpty(content) || isEmpty(label) || isEmpty(description)){
          layer.msg("必填项不能为空！",{anim: 6});
      }
      var id = '[(${docId})]';
      $.ajax({
          type: "POST",
          url: "/api/doc/update",
          data: {id:id,title:title,gitlabUrl:gitlabUrl,description:description,content:content,label:label},
          dataType: "json",
          success: function(data){
              if (data.code == "8200"){
                  layer.msg('更新成功，是否跳转详情页?', {
                      anim: 2,
                      time: 0 //不自动关闭
                      ,btn: ['确定', '取消']
                      ,yes: function(index){
                          layer.close(index);
                          location.href = "/detail/"+id;
                      }
                  });
              }else {
                  layer.alert(data.message, {icon: 2});
              }
          }
      });
  }

  var contentType = '[(${contentType})]';
  window.onload=function(){
  if (contentType == "MD"){
          $(".fly-edit").find("span")[5].remove();
          $(".fly-edit").find("span")[4].remove();
          $(".fly-edit").find("span")[3].remove();
          $(".fly-edit").find("span")[2].remove();
          $(".fly-edit").find("span")[1].remove();
          $(".fly-edit").find("span")[0].remove();
      }else if (contentType == "NT"){
          $(".fly-edit").find("span")[6].remove();
      }
  };

</script>

</body>
</html>